<?php
namespace Framework\Redis;

use Redis;

/**
 * 
 * Redis扩展文档 https://github.com/phpredis/phpredis/
 */
class Connection
{
	
	private $connection;

	function __construct()
	{
		$redis = new Redis();

		$redis->connect('127.0.0.1', 6379);

		$this->connection = $redis;
	}

	public function version($value='')
	{
		return $this->connection->info()['redis_version'];
	}

	public function ping($message='')
	{
		return $this->connection->ping($message);
	}

	/**
	 * 调用php官方Redis扩展类方法
	 */
	public function executeCommand($command, $params = [])
	{
		return call_user_func_array([$this->connection, $command], $params);
	}

	/**
	 * 通过魔术方法 把所有指令转为调用Redis指令
	 */
	public function __call($name, $params)
	{
		return $this->executeCommand($name, $params);
	}
}